<template>
	<view class="page">
		<view class="tab-list">
			<u-sticky>
				<view class="tab-list">
					<view class="tab-item" v-for="(item, index) in tabs" :key="index" @click="tabChange(item, index)">
						<view class="value" :class="current == index ? 'active' : ''">{{ item.name }}</view>
						<view class="line" v-if="current == index"></view>
					</view>
				</view>
			</u-sticky>
		</view>
		<view class="records-list">
			<view class="records-item" v-for="(item, index) in list" :key="index">
				<view>
					<view class="title">{{ item.type == 1 ? '支付宝' : '微信' }}打款</view>
					<view class="money">{{ item.amount }}</view>
				</view>
				<view class="item2">
					<view class="create-time">{{ item.createTime }}</view>
					<view v-if="item.status == 3" class="status">提现成功</view>
					<view v-if="item.status == 0" class="status" style="color:#10C65C">待审核</view>
					<view v-if="item.status == 99" class="status" style="color: #FF290B;">审核失败</view>
				</view>
				<view class="cause" v-if="item.status == 99">拒绝原因：{{ item.remarks || '--' }}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getBalanceWithdrawalRecord
	} from '@/apis/request.js';

	export default {
		data() {
			return {
				tabs: [{
						name: '全部',
						status: ''
					},
					{
						name: '待审核',
						status: 0
					},
					{
						name: '提现成功',
						status: 3
					},
					{
						name: '审核失败',
						status: 99
					}
				],
				current: 0,
				params: {
					pageNo: 1,
					pageSize: 10,
					status: '' //状态 0待审核 3提现完成 99提现拒绝
				},
				list: []
			};
		},
		methods: {
			tabChange(item, index) {
				this.current = index;
				this.params.status = item.status;
				this.init();
			},
			init() {
				this.params.pageNo = 1;
				this.list = [];
				this.getList();
			},
			toDetail(item) {
				uni.navigateTo({
					url: '/pages/order/orderDetail'
				});
			},
			getList() {
				getBalanceWithdrawalRecord(this.params).then(res => {
					if (this.params.pageNo == 1) {
						this.list = res.records;
					} else {
						if (this.list.length < res.total) {
							this.list = this.list.concat(res.records);
						} else {
							this.list = this.list;
						}
					}
				});
			}
		},
		onLoad() {
			this.getList();
		},
		onReachBottom() {
			this.params.pageNo++;
			this.getList();
		},
		onPullDownRefresh() {
			this.init();
			uni.stopPullDownRefresh();
		}
	};
</script>

<style scoped lang="scss">
	.page {
		background-color: #f2f2f2ff;
		height: 100%;
		min-height: 100vh;

		.tab-list {
			background-color: #fff;
			border-top: 2rpx solid #f1f1f1;
			width: 750rpx;
			background-color: #fff;
			display: flex;
			align-items: center;
			justify-content: space-around;

			.tab-item {
				display: flex;
				flex-direction: column;
				align-items: center;
				font-size: 28rpx;
				color: #999999;

				.value {
					padding: 30rpx 0 24rpx 0;
				}

				.line {
					width: 28rpx;
					height: 6rpx;
					border-radius: 3rpx;
					background: #32C59A;
				}
			}

			.active {
				font-size: 30rpx;
				color: #020202;
			}
		}

		.records-list {
			margin-top: 20rpx;
			background-color: #fff;

			.records-item {
				border-bottom: 2rpx solid #efefef;
				padding: 30rpx;

				.item2 {
					margin: 14rpx 0;
				}

				view {
					display: flex;
					align-items: center;
					justify-content: space-between;

					.title {
						font-size: 30rpx;
					}

					.money {
						font-size: 32rpx;
					}

					.create-time {
						font-size: 22rpx;
						color: #666666;
					}

					.status {
						font-size: 26rpx;
						color: #32C59A;
					}
				}

				.cause {
					color: #979797;
					font-size: 24rpx;
				}
			}
		}
	}
</style>